<div class="sub" id="incentive_message" style="display: none;">
    <p class='green-message'>{{ incentive_message }}</p>
</div>

{# Submitted files #}
{% if hide_submitted_files == false %}
    <h4>Submitted Files</h4>
    <div class="row">
        <div class="box col-md-6" id="submitted-files">
            {% for file in files %}
                {{ file.relative_name }} ({{ (file.size / 1024) | number_format(2) | default(-1) }}kb)

                {# download icon if student can download files #}
                {% if can_download %}
                    <button class = 'btn btn-primary' onclick='downloadFile("{{ file.path|url_encode }}", "submissions")' aria-label="Download {{file.relative_name}}"> Download
                        <i class="fas fa-download" title="Download the file"></i></button>
                {% endif %}

                {% if loop.index != files|length %}
                    <br />
                {% endif %}
            {% endfor %}
            {% if can_download and files|length > 1 %}
                <br />
                <br />
                Download all files: <a onclick='downloadSubmissionZip("{{ gradeable_id }}", "{{ user_id }}", "{{ display_version }}", "submission")' aria-label="Download zip of all files"><i class="fas fa-download" title="Download zip of all files"></i></a>
            {% endif %}
        </div>
        <div class="box col-md-6">
            <span id="submission_timestamp"> submission timestamp: {{ submission_time|date('m/d/Y h:i:s A') }}</span> <br />
            days late: {{ days_late }} (before extensions)<br />
            {% if results is defined %}
                grading time: {{ grade_time }} seconds<br />
                {% if num_autogrades > 1 %}
                    <br />
                    number of re-autogrades: {{ num_autogrades - 1 }}<br />
                    last re-autograde finished: {{ grading_finished|date('m/d/Y h:i:s A') }}<br />
                {% else %}
                    queue wait time: {{ wait_time }} seconds<br />
                {% endif %}
                {% if is_vcs %}
                    git commit hash:
                    {% if revision %}
                        {{ revision[0:7] }}
                    {% else %}
                        None
                    {% endif %}
                    <br />
                {% endif %}
            {% else %}
                grading not complete
            {% endif %}
        </div>
    </div>
{% else %}
    {# Keep the Submission date to let Confetti parse the date #}
    <span hidden id="submission_timestamp"> submission timestamp: {{ submission_time|date('m/d/Y h:i:s A') }}</span> <br />
{% endif %}
{# /Submitted files #}

<div class="sub">
    {% if show_testcases %}
        <h4>Autograding Results</h4>
    {% endif %}

    {# Actual results #}
    {% if in_queue or grading %}
        {% if grading %}
            <p class="red-message">
                This submission is currently being graded.
            </p>
        {% else %}
            <p class="red-message">
                This submission is currently in the queue to be graded. Your submission is number {{ queue_pos }} out of {{ queue_total }}.
            </p>
        {% endif %}
        <script type="text/javascript">
            checkRefreshPage("{{ check_refresh_submission_url|e('js') }}")
        </script>
    {% elseif results is not defined %}
        <p class="red-message">
            Something has gone wrong with grading this submission. Please contact your instructor about this.
        </p>
    {% else %}
        {# Has results! #}
        {% if show_incentive_message %}
            <script type="text/javascript">
                (function() {
                    ('#incentive_message').show();
                })();
            </script>
        {% endif %}
    {% endif %}

    {{ result_text|raw }}
</div>
